﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.Threading;

namespace TankWin.Classes
{
    class ObjBullet
    {
        protected Point _position;
        protected EStatusDirect _direct;
        protected EStatusTank _status;
        const int _Move_bullet = 10;
        const int _Size = 6;
        const int _Destroy_Size = 30;
        const int _Time_Effect = 250;
        /////////////////
        #region property
        public Point Position
        {
            get{return _position;}
            set { _position = value; }
        }
        public EStatusDirect Direct
        {

            get { return _direct; }
            set { _direct = value; }
        }
        public EStatusTank Status
        {

            get { return _status; }
            set { _status = value; }
        }
        #endregion
        ////////////////////////////////
        public ObjBullet(Point _p, EStatusDirect _d)
        {
            _position = _p;
            _direct = _d;
            _status = EStatusTank.IsDestroy;
        }
        public void MoveFoward()
        {
            switch (_direct)
            {
                    
                case EStatusDirect.Up:
                    Console.WriteLine("dichuyen");
                    _position.Y -= _Move_bullet;
                    break;
                case EStatusDirect.Down:
                    _position.Y += _Move_bullet;
                    break;
                case EStatusDirect.Left:
                    _position.X -= _Move_bullet;
                    break;
                case EStatusDirect.Right:
                    _position.X += _Move_bullet;
                    break;
            }

        }
        public void Draw(Graphics _g)
        {

            if (_status == EStatusTank.IsAlive)
            {
                Point _p = new Point(_position.X -_Size/2, _position.Y -_Size/2);
                _g.FillEllipse(Brushes.Pink, new Rectangle(_p, new Size(_Size, _Size)));

            }
        }
        public void Destroy(Graphics _g)
        {
            Thread t = new Thread(() =>
            {
                try
                {
                    _g.DrawImageUnscaled(global::TankWin.ImageTank.small_burn, _position.X - 15, _position.Y - 15);
                }
                catch (System.Exception ex)
                {

                }
            }
                );
            t.Start();
        }
    }
}
